<template>
  <div class="container">
    <el-card class="">
      <el-form
        ref="form"
        :rules="$rules"
        :model="model"
        status-icon
        label-width="160px"
        class=""
      >
        <p class="red">起征点以下金额设置:</p>
        <el-form-item
          prop="PayMaxAmount"
          :label="$language.local('PayMaxAmount')"
        >
          <xy-decimal v-model="model.PayMaxAmount"></xy-decimal>
        </el-form-item>
        <p class="red">起征点以上金额设置:</p>
        <el-form-item
          prop="MonthAcceptanceMaxAmount"
          :label="$language.local('MonthAcceptanceMaxAmount')"
        >
          <xy-decimal v-model="model.MonthAcceptanceMaxAmount"></xy-decimal>
        </el-form-item>
        <el-form-item
          prop="YearAcceptanceMaxAmount"
          :label="$language.local('YearAcceptanceMaxAmount')"
        >
          <xy-decimal v-model="model.YearAcceptanceMaxAmount"></xy-decimal>
        </el-form-item>
      </el-form>
      <div class="form-footer">
        <el-button type="primary" @click="onSubmit('form')">保存</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      model: {
        // PayMaxAmount: 93500,
        // MonthAcceptanceMaxAmount: 2000000,
        // YearAcceptanceMaxAmount: 5000000,
      },
      api: "/api/systemSet",
    };
  },
  created() {
    this.getData();
  },
  methods: {
    async getData() {
      let response = await this.$http.get("/api/systemSet/GetModel/1?type=1");
      console.log(response);
      this.model = response.data.Data;
    },
    async onSubmit(formName) {
      let valided = await this.$refs[formName].validate().catch((err) => err);

      if (!valided) {
        return;
      }

      let response = await this.$http.post(
        "/api/systemSet/tradeSet/1",
        null,
        this.model
      );
      console.log(response);
      if (response.data.Code == 200) {
        this.$message.success("修改成功");
      }
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  .el-card {
    width: 62%;
    padding: 2rem 4rem;
  }
}
</style>
